package com.wangyadong.hobby.thread;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

class GoodListHelper <E> {
    public List<E> list = Collections.synchronizedList(new ArrayList<E>());

    public E putIfAbsent(E x) {
        synchronized (list) {
            boolean absent = !list.contains(x);
            if (absent)
                list.add(x);
            return x;
        }
    }
}